<?php
namespace Home\Controller;
use Think\Controller;
class MainController extends EmptyController{
	
	function index(){

		// 不缓存
		// C('HTML_CACHE_ON', false);


		//前进后退
		if($_GET['go'] == 'next'){
			$_GET['year']	= $_GET['month'] >= 12 ? $_GET['year']+1:$_GET['year'];
			$_GET['month']	= $_GET['month'] >= 12 ? 1:$_GET['month']+1;
		}elseif($_GET['go'] == 'prev'){
			$_GET['year']	= $_GET['month'] <= 1 ? $_GET['year']-1:$_GET['year'];
			$_GET['month']	= $_GET['month'] <= 1 ? 12:$_GET['month']-1;
		}else{
			$_GET['year']	= !$_GET['year']  ? date ( 'Y' ) : $_GET['year'];
			$_GET['month']	= !$_GET['month'] ? date ( 'n' ) : $_GET['month'];
		}


		$line = mktime ( 0, 0, 0, $_GET['month'], 1, $_GET['year'] );

		$this->title = date('Y-m', $line);

		//选定月有多少天？
		$this->total_day = date ( 't', $line );

		//第一天星期几
		$this->week_day = date ( 'N', $line );

		//一共多少行
		$this->row = $this->total_day + $this->week_day > 35 ? 6 : 5;

		//事件列表
		// $this->list = R('calendar/_color_note', array($_GET['sort']));
		// dump($this->_color_note);

		//列表中颜色使用
		// $table = 'calendar_' . $_GET['sort'];
		// $o = M($table);

		// $o->field('day,color');
		// $o->where("year = {$_GET['year']} AND month = {$_GET['month']}");
		// $o->order('day ASC');
		// $tmp = $o->select();

		//模拟数据
		$this->active_day = array(
			5	=> 1,
			7	=> 1,
			12	=> 0,
			14	=> 1,
			19	=> 1,
			21	=> 1,
			26	=> 1,
			28	=> 1,
		);


		$this->display();
	}
}